package com.gregbugaj.gps;

import java.util.List;

public class Route {
	private List<RoutePoint> points;

	public List<RoutePoint> getPoints() {
		return points;
	}

	public void setPoints(List<RoutePoint> points) {
		this.points = points;
	}

	public RoutePoint getFirst(){
		return this.points.get(0);
	}
	
	public RoutePoint getLast(){
		return this.points.get(points.size()-1);
	}
	
	
	/**
	 * Get distance of the total route
	 * @return
	 */
	public double getDistanceInKM(){
		double total=0;
		for(int i=0;i<points.size()-1;i=i+3){
			RoutePoint a=points.get(i);
			RoutePoint b=points.get(i+1);
			double distance=getDistanceInKM(a, b);
			total+=distance;
		//	System.out.println(i+"  = "+distance+"   = "+a+b);
		}
		return total;
	}

	
	public double getDistanceInKM(RoutePoint a, RoutePoint b){
		return 	DistanceSpeedUtil.getDistanceInKM(a.getLatitude(), a.getLongitude(), b.getLatitude(), b.getLongitude());
	}

}
